<template>
  <el-dialog
    :title="title"
    :visible.sync="openDlg"
    width="500px"
    append-to-body
    destroy-on-close
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="220px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="奖学金名称" prop="typeName">
              <el-input style="width:100%" v-model="form.typeName" placeholder="请输入国家奖学金名额" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="金额" prop="bonusMoney">
              <el-input style="width:100%" v-model="form.bonusMoney"  placeholder="请输入国家奖学金金额" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="名额" prop="personNum">
              <el-input style="width:100%" v-model="form.personNum"  placeholder="请输入国家励志奖学金名额" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="是否二级学院可以导入配置" prop="isSet">
              <el-radio-group 
                v-model="form.isSet"
                >
                <el-radio :label="0">否</el-radio>
                <el-radio :label=" 1">是</el-radio>
              </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="奖项不可兼得" prop="isHaveBoth">
              <el-radio-group 
                v-model="form.isHaveBoth"
                >
                <el-radio :label="0">否</el-radio>
                <el-radio :label=" 1">是</el-radio>
              </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="四大组织" prop="orgFlag">
              <el-radio-group 
                v-model="form.orgFlag"
                >
                <el-radio :label="0">否</el-radio>
                <el-radio :label=" 1">是</el-radio>
              </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="顺序">
              <el-input-number
                size="mini"
                :min="0"
                :max="9999"
                placeholder="请输入顺序"
                v-model="form.sort">
            </el-input-number>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="openDlg = false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { 
  schoolScholarshipEdit
} from "@/api/poorStudent-scholarship/plan.js";
export default {
  name:"schoolScholarshipEdit",
  data () {
      return {
          title: '编辑',
          openDlg: false,
          // 表单参数
          form: {
            typeName: '',
            bonusMoney: null,
            personNum: null,
            isSet: '1'
          },
          // 表单校验
          rules: {
            typeName: [
              { required: true, message: '请输入奖学金名称', trigger: 'blur' }
            ],
            bonusMoney: [
              { required: true, message: '请输入奖学金金额', trigger: 'blur' }
            ],
            personNum: [
              { required: true, message: '请输入奖学金名额', trigger: 'blur' }
            ]
          }
      }
  },
  methods:{
      open (rowdata) {
          this.form = {
            ...rowdata
          }
          this.openDlg = true
      },
      submitForm () {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            schoolScholarshipEdit(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.openDlg = false;
              this.$emit("onSearch")
            });
          }
        });
      },
  }

}
</script>

<style lang="scss" scoped>
  .planTotal{
      display: flex;
      font-size: 13px;
      color: #606266;
      &-left{
          margin-left: 30px;
      }
      &-right{
          margin-left: 20px;
      }
  }
</style>